package org.example.service.imp;

import org.example.dao.TicketDao;
import org.example.domain.Ticket;
import org.example.service.TicketService;
import org.example.util.HutoolUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TicketServiceImp implements TicketService {
    @Autowired
    private TicketDao ticketDao;
    @Autowired
    private HutoolUtil hutoolUtil;
    @Override
    public int saveOne(Ticket ticket) {
        if (ticket == null) return 0;
        return ticketDao.saveOne(ticket);
    }

    @Override
    public Ticket searchByTicket(String ticket) {
        if (ticket == null || ticket.equals("")|| ticket.equals(" ")) return null;
        return ticketDao.searchByTicket(ticket);
    }

    @Override
    public int deleteTicketByTicket(String ticket) {
        if (ticket == null || ticket.equals("")|| ticket.equals(" ")) return 0;
        return ticketDao.deleteTicketByTicket(ticket);
    }

    @Override
    public int exit(String ticket) {
        if (hutoolUtil.stringIsEmpty(ticket)) return 0;
        return ticketDao.deleteTicketByTicket(ticket);
    }
}
